package pcsr.drivers.nxtDriver;

enum NXTSensorType {
	NOSENSOR( 0 ), 
	SWITCH( 1 ), 
	TEMPERATURE( 2 ), 
	REFLECTION( 3 ), 
	AMGLE( 4 ), 
	LIGHTACTIVE( 5 ), 
	LIGHTINACTIVE( 6 ), 
	SOUNDDB( 7 ), 
	SOUNDDBA( 8 ), 
	CUSTOM( 9 ),
	LOWSPEED( 10 ),
	LOWSPEED9V( 11 ),
	NONESENSORTYPES( 12 );
	
	private int sensorType;
	
	private NXTSensorType( int value )
	{
		if(value < 0 || value > 12)
		{
			throw new IllegalArgumentException("NXTSensorType values between 0 and 12.");
		}
		sensorType = value;
	}
	
	public int GetTypeValue( )
	{
		return sensorType;
	}
	
	public static NXTSensorType GetTypeByValue( final int value )
	{
		switch (value) 
		{
			case 0:
				return NOSENSOR;
			case 1:
				return SWITCH;
			case 2:
				return TEMPERATURE;
			case 3:
				return REFLECTION;
			case 4:
				return AMGLE;
			case 5:
				return LIGHTACTIVE;
			case 6:
				return LIGHTINACTIVE;
			case 7:
				return SOUNDDB;
			case 8:
				return SOUNDDBA;
			case 9:
				return CUSTOM;
			case 10:
				return LOWSPEED;
			case 11:
				return LOWSPEED9V;
			case 12:
				return NONESENSORTYPES;
		}
		return null;
	}
	
}
